﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using MediaFactory;
using CAD = Cad.CAD;

namespace DbDao {
   public class MediaDao : I_MediaDAO
    {

        //private RedxModel Model;
       private Cad.CAD Model;

        public MediaDao()
        {
            //this.Model = new RedxModel();
            this.Model = new Cad.CAD();
        }

        public Dictionary<String, String> getAllMedias()
        {
            return Model.SelectAll();
        }

        public bool saveNewMedia(I_Media media)
        {
            try
            {
                this.Model.InsertMedia( media );
               // this.Model.Media.Add( getDummyMedium() );
                //this.Model.SaveChanges();
                return true;
            }
            catch (Exception ex)
            {
                return false;
            }
        }

        public void savePerfData(int cpuUsage, int ramUsage, double dDUsage, bool startAllowed) {
            this.Model.InserPerf(cpuUsage, ramUsage, dDUsage, startAllowed);
        }

        private Video getDummyMedium()
        {
            Video med = new Video();
            med.Path = "P";
            med.Name = "N";
            med.Size = 22;
            return med;
        }
    }
}
